<!DOCTYPE html>
<html>
	{include file="public/_header" /}
	<style type="text/css">
		.layui-table th {
			background: #f5f7fa;
		}

		.table-form .layui-input,
		.table-form .layui-select,
		.table-form .layui-textarea {
			height: 32px;
			line-height: 1;
		}

		.layui-layout-admin {
			position: fixed;
			left: 0px;
			right: 0;
			bottom: 0;
			height: 40px;
			line-height: 40px;
			padding: 10px 15px;
			background-color: #fff;
			text-align: center;
		}

		.pics-item {
			/* padding: 10px;/ */
		}

		.pics {
			width: 100px;
			height: 80px;
			float: left;
			padding: 10px 4px;
			padding-bottom: 20px;
		}

		.pics img {
			border: 1px solid #eee;
			border-bottom: none;
			width: 100%;
			height: 100%;
		}

		.pics span input {
			width: 98px;
			display: inline-block;
		}
		.layui-upload-list{
			margin: 0!important;
			float: left;
		}
		.layui-upload-img {
			width: 45px;
			height: 38px;
			margin: 0 10px;
			border:1px solid #ddd
		}
	</style>
	<body style="margin-bottom: 80px;">
		<div class="x-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a>
					<cite>数据库备份</cite></a>
			</span>
			<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()"
			 title="刷新">
				<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
			</a>
		</div>
		<form class="layui-form" action="">
			<div style="padding: 20px; background-color: #F2F2F2;">
				<div class="layui-row layui-col-space15">
					<div class="layui-col-md9">
						<div class="layui-card">
							<div class="layui-card-header">标题</div>
							<div class="layui-card-body">
								<div class="layui-form">

									<table class="layui-table table-form">
										<colgroup>
											<col width="150">
											<col>
										</colgroup>
										<tbody>
											<tr>
												<th style="text-align:right">标题</th>
												<td><input type="text" name="title" style="max-width: 400px;" required lay-verify="required" placeholder="请输入标题"
													 autocomplete="off" class="layui-input"></td>
											</tr>
											<tr>
												<th style="text-align:right">关键词</th>
												<td><input type="text" name="title" style="max-width: 400px;" required lay-verify="required" placeholder="请输入标题"
													 autocomplete="off" class="layui-input"></td>
											</tr>
											<tr>
												<th style="text-align:right">来源</th>
												<td><input type="text" name="title" style="max-width: 400px;" required lay-verify="required" placeholder="请输入标题"
													 autocomplete="off" class="layui-input"></td>
											</tr>
											<tr>
												<th style="text-align:right">描述</th>
												<td><textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea></td>
											</tr>
											<tr>
												<th style="text-align:right">缩略图</th>
												<td>
													<div class="layui-upload">
														<button type="button" style="float: left;" class="layui-btn layui-btn-primary" id="test1">上传图片</button>
														<div class="layui-upload-list">
															<img class="layui-upload-img" src="__STATIC__/admin/images/image.png" id="demo1">
															<p id="demoText"></p>
															<input type="hidden" name="logo" id="logo" value="" />
														</div>
													</div>

												</td>
											</tr>
											<tr>
												<th style="text-align:right">组图</th>
												<td>
													<div class="pics-item">
														<div class="pics">
															<img src="__STATIC__/admin/images/bg.png" alt="">
															<span><input type="text"></span>
														</div>
														<div class="pics">
															<img src="__STATIC__/admin/images/bg.png" alt="">
															<span><input type="text"></span>
														</div>
														<div class="pics">
															<img src="__STATIC__/admin/images/bg.png" alt="">
															<span><input type="text"></span>
														</div>
														<div class="pics">
															<img src="__STATIC__/admin/images/bg.png" alt="">
															<span><input type="text"></span>
														</div>
													</div>

												</td>
											</tr>
											<tr>
												<th style="text-align:right">描述</th>
												<td><textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea></td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-col-md3">
						<div class="layui-card">
							<div class="layui-card-header">标题</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-layout-admin">
				<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
			</div>
		</form>
	</body>
	<script>
		//Demo
		layui.use(['form', 'upload'], function() {
			var form = layui.form;
			var $ = layui.jquery,
				upload = layui.upload;
			//普通图片上传
			var uploadInst = upload.render({
				elem: '#test1',
				url: "{:url('admin/Upload/addImages')}",
				before: function(obj) {
					//预读本地文件示例，不支持ie8
					obj.preview(function(index, file, result) {
						$('#demo1').attr('src', result); //图片链接（base64）
					});
				},
				done: function(res) {
					//如果上传失败
					if (res.code > 0) {
						return layer.msg('上传失败');
					} else {
						$("#logo").val(res.data);
					}
					//上传成功
				},
				error: function() {
					//演示失败状态，并实现重传
					var demoText = $('#demoText');
					demoText.html(
						'<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
					demoText.find('.demo-reload').on('click', function() {
						uploadInst.upload();
					});
				}
			});
			//监听提交
			form.on('submit(formDemo)', function(data) {
				layer.msg(JSON.stringify(data.field));
				return false;
			});
		});
	</script>
</html>
